/*
 * loadscreen.hpp
 *
 *  Created on: 21/12/2008
 *      Author: smaxll
 */

#ifndef LOADSCREEN_HPP_
#define LOADSCREEN_HPP_

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>

#include <string>
#include <iostream>


class loadscreen {
public:
    // Preferred constructor
    explicit loadscreen(SDL_Surface *screen, const int &percent = 0);
    ~loadscreen() {
        if (logo_surface_) {
            SDL_FreeSurface (logo_surface_);
        }
    }

    // Function to display a load progress bar.
    void set_progress(const int percentage=0, const std::string &text="", const bool commit=true);
    //! Function to increment the progress bar.
    void increment_progress(const int percentage=1, const std::string &text="", const bool commit=true);
    //! Function to draw a blank screen.
    void clear_screen(const bool commit=true);

    //! A global loadscreen instance that can be used to avoid
    //! passing it on to functions that are many levels deep.
    static loadscreen *global_loadscreen;

private:
    SDL_Surface *logo_surface_;
    SDL_Surface *screen_;
    SDL_Rect text_area;
    bool logo_drawn;
    int pby_offset_;
    int prcnt;
};

#endif /* LOADSCREEN_HPP_ */
